<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<html>
	<head>
		<title>订单模版导入</title>
		<script type="text/javascript">
	function ajaxfindOrdenoSource(item) {
		$.ajax({
			type : 'post',
			url : '${ctx}/v2/customers/ajaxfindOrdenoSource',
			data : 'customerCode=' + item.value,
			dataType : 'json',
			success : function(data) {
				var tempString = "";
				var tempString2 = "<option ></option>";
				if (data.status == "1") {
					$.each(data.content,function(i) {
						tempString += "<option value="+data.content[i].ordenoSourceCode+">"
								+ data.content[i].ordenoSourceName;
					});
					$.each(data.areaGroupCode,function(i) {
						tempString2 += "<option value="+data.areaGroupCode[i].groupCode+">"
								+ data.areaGroupCode[i].groupName;
					});
				} else {
					alert(data.content);
				}
				$("#ordenoSourceCode").html(tempString);
				$("#areaGroupCode").html(tempString2);
				$("#ordenoSourceCode").trigger("chosen:updated");
				$("#areaGroupCode").trigger("chosen:updated");
			},
			error : function() {
				alert("获取信息错误！");
			}
		});
	}
</script>


	</head>

	<body>
	<div class="row">
	<div class="col-md-12">
			<div class="col-sm-4">
			<div class="input-group col-sm-12">
					<label class="input-group-text">客户名称:</label>
					<select class="form-control" onchange="ajaxfindOrdenoSource(this)" id="customers">
						<option value=""></option>
						<c:forEach items="${customers }" var="o">
							<option value="${o.customerCode}"> ${o.customerName } </option>
						</c:forEach>
					</select>
			</div>
			</div>
			<div class="col-sm-4">
			<div class="input-group col-sm-12">
					<label class="input-group-text">仓库:</label>
					<select class="form-control" onchange="" id="areaGroupCode">
					</select>
			</div>					
			</div>
			<div class="col-sm-4">
			<div class="input-group col-sm-12">
					<label class="input-group-text">订单平台:</label>
					<select class="form-control" id="ordenoSourceCode">
						<c:forEach items="${sources }" var="o">
							<option value="${o.ordenoSourceCode}">
								${o.ordenoSourceName }
							</option>
						</c:forEach>
					</select>
			</div>
			</div>
		</div>
		</div>
		<div id="fullbg"></div>
		<div id="dialog">
			<div>
				<img src="${ctx }/static/022.gif"></img>
			</div>
		</div>

		<div class="row">
		<div class="col-md-12">
		<form id="form2" method="post" enctype="multipart/form-data">
			<table class="table table-striped table-bordered table-condensed">
				<thead>
					<tr bgcolor="#3FA8F3">
						<th colspan="14"
							style="height: 30px; font-size: 18px; color: white; vertical-align: middle;">
							商品导入模版(不支持公式)
						</th>
					<tr>
				</thead>
				<tbody>
					<tr>
						<td>
							<input name="file" class="btn" type="file">
						</td>
					</tr>
					<tr>
						<td>
							<span>覆盖已有SKU数据:</span>	<input type="checkbox" id="overWrite">
						</td>
					</tr>
					<tr>
						<td style="height: 50px; vertical-align: middle;">
							<button type="submit" class="btn btn-primary" id="skuFormUpload">
								开始导入
							</button>
							<button type="reset" class="btn">
								重置
							</button>
						</td>
					</tr>
				</tbody>
			</table>
		</form>
		</div>
		</div>

		<div class="row">
        <div class="col-md-12">
		<form id="form1" method="post" enctype="multipart/form-data">
			<table class="table table-striped table-bordered table-condensed">
				<thead>
					<tr bgcolor="#3FA8F3">
						<th colspan="14" style="height: 30px; font-size: 18px; color: white; vertical-align: middle;">
							订单数据源模版导入
						</th>
					<tr>
				</thead>
				<tbody>
					<tr>
						<td style="height: 50px; vertical-align: middle;">
							<a class="btn" href="${ctx}/leadMasterplate/updownExcel">模板下载</a>
						</td>
					</tr>
					<tr>
						<td style="height: 50px; vertical-align: middle;">
							<input name="file" class="btn" type="file">
						</td>
					</tr>
					<tr>
						<td style="height: 50px; vertical-align: middle;">
							<button type="submit" class="btn btn-primary" id="formUpload">
								开始导入
							</button>
							<button type="reset" class="btn">
								重置
							</button>
						</td>
					</tr>
				</tbody>
			</table>
		</form>
		</div>
		</div>
		<script type="text/javascript">
	$("#formUpload").click(
			function() {
				
				var erpType = $("#ordenoSourceCode").val();
				var customers = $("#customers").val();
			    var areaGroupCode = $("#areaGroupCode").val();
				if(null == customers||customers == "null"||customers.length<=0){
					alert("请选择客户名称...") ;
					return ;
				}
				if(null == areaGroupCode||areaGroupCode == "null"||areaGroupCode.length<=0){
					alert("请选择仓库...") ;
					return ;
				}
				showBg();
				$("#form1").attr(
						"action",
						"${ctx}/leadMasterplate/lead/" + customers + "/"+ areaGroupCode+ "/"+ erpType);
			});

	$("#skuFormUpload").click(function() {
		showBg();
		var customers = $("#customers").val();
		if(null == customers||customers == "null"||customers.length<=0){
			alert("请选择客户名称...") ;
			return ;
		}
		var overWrite = $("#overWrite").is(":checked");
		//alert(overWrite);
		$("#form2").attr("action", "${ctx}/leadSkuMasterplate/leadSku/"+customers+"/sku?overWrite="+overWrite);
	});
</script>

	</body>
</html>
